﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace background.Manager.Enterprise.Message.Action {
    /// <summary>
    /// msg 的摘要说明
    /// </summary>
    public class msg: IHttpHandler {

        public void ProcessRequest(HttpContext context) {
            context.Response.ContentType = "text/plain";
            HttpRequest r=context.Request;
            string ret=string.Empty;
            switch(r["action"].ToString()) {
                case "add"://State=1不需要审核 =0需要审核
                    ret= Codes.Message.add(r["Content"], r["UserName"], r["SourceUrl"], r["SourceParameter"], r["SourceTag"]).ToString().ToLower();
                    break;
                case "reply":
                    ret= Codes.Message.reply(r["ReplyContent"], int.Parse(r["ID"])).ToString().ToLower();
                    break;
                case "delete":
                    ret= Codes.Message.deleteMass(r["idList"]).ToString().ToLower();
                    break;
                case "massState":
                    ret= Codes.Message.MassState(int.Parse(r["State"]),r["idList"]).ToString().ToLower();
                    break;
                case "Manager"://审核，内容或是否显示
                    if(r["setType"].ToString()=="c") {
                        ret=Codes.Message.Manager(r["Content"], int.Parse(r["ID"])).ToString().ToLower();
                    } else {
                        ret=Codes.Message.reply(r["Content"], int.Parse(r["ID"])).ToString().ToLower();
                    }
                    break;
                case "getCount":
                    ret=Codes.Message.getListCount(r["KEY"]).ToString();
                    break;
                case "getList":
                    ret=Codes.h.getJson(Codes.Message.getList(r["KEY"], int.Parse(r["pageindex"]), int.Parse(r["pagesize"])));
                    break;
            }
            context.Response.Write(ret);
        }

        public bool IsReusable {
            get {
                return false;
            }
        }
    }
}